//	---------------------------------------------------------------------------
//	jQuery plug-in to handle web application logs
//	Rolando Santamaria Maso <kyberneees@gmail.com>
//	---------------------------------------------------------------------------
//	This program is free software; you can redistribute it and/or modify it
//	under the terms of the GNU Lesser General Public License as published by the
//	Free Software Foundation; either version 3 of the License, or (at your
//	option) any later version.
//	This program is distributed in the hope that it will be useful, but WITHOUT
//	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//	FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
//	more details.
//	You should have received a copy of the GNU Lesser General Public License along
//	with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
//	---------------------------------------------------------------------------
(function($){
	
	/**
	 * Logger environment {dev, prod}
	 */
	$.logger = {
		env: "dev",
		handler: (window.console) ? window.console : {
			log: function(msg){
				//Dialog messages logger if not console detected
				alert(msg.toString());
			}
		}
	};
	
	/**
	 * Log a message on the console
	 * 
	 * @msg The message to log
	 * @type The log type {error, debug, info, warning}
	 */
	$.log = function(msg, type) {
		if (undefined == type){
			type = "debug";
		}
		if ($.logger.env == "prod" && type != "error"){
			return;
		}
		
		if (typeof(msg) == "string"){
			msg = ">> " + type + ": " + msg;
		}
		
		$.logger.handler.log(msg);
	};
}(jQuery));